;;;

(in-package :cl-user)

#-xlui
(defpackage :XML
  (:use :common-lisp)
  (:export "XML-SERIALIZER" "PARSE-FILE-NAME"))

(defparameter *dt.root-path* (make-pathname
                              :directory (pathname-directory *load-truename*)))
(defparameter *dt.library-path* (merge-pathnames "Library/**" *dt.root-path*))
(defparameter *dt.data-path* (merge-pathnames "data/" *dt.root-path*))

(setf (logical-pathname-translations "dt")
      (list (list "data;*.*.*" *dt.data-path*)
	    (list "library;**;*.*.*" *dt.library-path*)
            (list "**;*.*.*" *dt.root-path*)))

;(load (merge-pathnames "Library/cells/utils-kt.asd" *dt.root-path*))
;(load (merge-pathnames "Library/cells/cells.asd" *dt.root-path*))

;(defparameter KR-Version-Number "2.3.4")


(asdf:defsystem :dreaming-tree-base
  :components (;(:file "auxfns")
	       (:file "XMLisp")
	       (:file "defpkg")
	       (:file "logging")
	       #+ccl (:file "foreign-arrays")
	       (:file "shader")
	       (:file "gllib")
	       (:file "attribute-definitions")
               (:file "math")
	       (:file "matrix")
               (:file "vector")
	       (:file "linear-algebra")
	       (:file "eigen")
	       (:file "least-squares")
	       (:file "lcpsolver")
               (:file "quaternion")
	       (:file "transformation")
	       (:file "classes")
	       (:file "bounding-volumes")	       
	       (:file "distance")
	       (:file "intersection")
	       (:file "culling")
	       (:file "render-states")
	       (:file "r-tree")
	       (:file "geometry")
	       (:file "trimesh")
	       (:file "physics")
	       (:file "camera")
	       (:file "controller")
	       (:file "renderer"))
  :serial t
  :depends-on (:iterate :alexandria :cl-ppcre :log5 :cffi :cl-opengl :cl-glu))

(asdf:defsystem :dreaming-tree-xlui
  :name "OpenGL Extensions."
  :components ((:file "gllib")
	       #+darwin-target (:file "texture-arb")
               (:file "xlui-renderer"))
  :serial t
  :depends-on (:dreaming-tree-base :cl-wo))

(asdf:defsystem :dreaming-tree-sdl
  :name "OpenGL Extensions."
  :components ((:file "texture-arb")
	       (:file "gldraw")
	       (:file "sdl-renderer"))
  :serial t
  :depends-on (:dreaming-tree-base :lispbuilder-sdl))

(asdf:defsystem :dreaming-tree-cocoa
  :components ((:file "cocoa-renderer"))
  :serial t
  :depends-on (:dreaming-tree-base))

(asdf:defsystem :dreaming-tree-qt
  :components ((:file "qt-renderer"))
  :serial t
  :depends-on (:dreaming-tree-base :qt))

; :clsql-sqlite3))

;;; Dont forget: physics and geometry!

#+xlui
(asdf:defsystem :dreaming-tree
    :name "The Dreaming Tree is dying."
  :components ((:file "chipmunk")
	       (:file "observer")
	       (:file "game-editor")
	       (:file "lui-support") ; Yes, this really needs to come first.
	       (:file "cocoa-support")
	       (:file "stage"))
  :serial t
  :depends-on (:lib.gl))

;; (defun build-dt-app ()
;;   (unless (find-package :xlui)
;;     (load "~/Library/CCL/systems/xmlisp-read-only/XMLisp/sources/XMLisp-init.lisp"))
;;   (asdf:oos 'asdf:load-op :dreaming-tree)
;;   (cl::build-application :name "DreamingTree"
;;                          :directory (translate-logical-pathname "dt:")
;;                          :copy-ide-resources t))
